use std::ptr::NonNull;

/// 内存块分类枚举
#[derive(Debug, PartialEq, Eq)]
pub(crate) enum ChunkCategory {
    Small,  // 0-64 字节
    Medium, // 65-256 字节
    Large,  // 257+ 字节
}

/// 内存块元数据结构
pub(crate) struct MemoryBlock {
    pub(crate) size: usize,
    pub(crate) is_free: bool,
    pub(crate) next: Option<NonNull<MemoryBlock>>,
}

/// Aligns the given size up to the specified alignment boundary
///
/// # Functionality
/// Calculates the minimum aligned size that is:
/// - Greater than or equal to the original input size
/// - Divisible by the alignment value
///
/// # Parameters
/// - `size`: The original size to be aligned
/// - `align`: The alignment boundary (must be a power of 2)
///
/// # Returns
/// The aligned size
///
/// # Examples
/// ```
/// let aligned_size = align_up(13, 8);  // Returns 16
/// assert_eq!(aligned_size % 8, 0);     // Ensures divisibility by 8
/// ```
///
/// # Bit Manipulation Explanation
/// The function works by:
/// 1. Adding (align - 1) to ensure rounding up
/// 2. Using bitwise AND with the complement of (align - 1)
///    to truncate to the nearest alignment
#[inline]
pub(crate) fn align_up(size: usize, align: usize) -> usize {
    (size + align - 1) & !(align - 1)
}
